<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>更新邮箱</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" th:href="@{/css/bootstrap.css}" type="text/css">

    <!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
    <link rel="stylesheet" th:href="@{/css/bootstrap-theme.min.css}">

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script th:src="@{/js/bootstrap.min.js}"></script>
    <script th:src="@{/js/jquery.min.js}" type="application/javascript"></script>
    <script>
        $(document).ready(function () {
            $("#myFrom").submit(function () {
              let username=$("#username").val();
              let password=$("#password").val();
              let email=$("#email").val();
              if(username.length==0){
                  alert("不能为空!")
                  return false;
              }
              if(username.length<12){
                    alert("学号输入有误!")
                    return false;
                }
              if(password.length==0){
                  alert("不能为空!")
                  return false;
              }
                var reg = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;
                if(!reg.test(email)){
                    alert("邮箱格式正确");
                    return false;
                }
                $("#sub").attr('disabled','true')
                $("#back").attr('disabled','true')
            })
            $("#back").click(function () {
                window.location.href="/"
            })
        })
    </script>

</head>
<body>
<h1 style="text-align: center">更新邮箱</h1>
<div>
    <form id="myFrom" class="form-horizontal" action="/updateemail" method="post">
        <div class="form-group">
            <label for="username" class="col-sm-5 control-label"> 学 &emsp; 号:</label>
            <div class="col-sm-2">
                <input type="text" name="username" class="form-control" id="username" placeholder="请输入学号">
            </div>
            <div style="color: red" th:text="${msg}"></div>
        </div>
        <div class="form-group">
            <label for="password" class="col-sm-5 control-label">isp 密 码:</label>
            <div class="col-sm-2">
                <input type="password" class="form-control" name="password" id="password" placeholder="请输入isp密码">
            </div>
        </div>
        <div class="form-group">
            <label for="password" class="col-sm-5 control-label">通知邮箱:</label>
            <div class="col-sm-2">
                <input type="email" class="form-control" name="email" id="email" placeholder="请输入邮箱">
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-5 col-sm-7">
                <button type="submit" id="sub" class="btn btn btn-primary">确定</button>
                <button type="button" id="back" class="btn btn btn-info">返回</button>
            </div>
        </div>

    </form>
</div>
</body>
</html>